package com.saishi.servlet;

import com.saishi.dao.ExamDao;
import com.saishi.dao.impl.ExamDaoImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.Date;
import java.sql.SQLException;
import java.util.List;

@WebServlet("/exam/*")
public class ExamServlet extends BaseServlet {
    ExamDao dao=new ExamDaoImpl();
    public void add(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException {
        System.out.println("1");
        String examname=request.getParameter("exam_name");
        String examstartdate= request.getParameter("exam_start_date");
        String examenddate= request.getParameter("exam_end_date");
        int examscore=Integer.parseInt( request.getParameter("exam_score"));
        int examtimelimit=Integer.parseInt( request.getParameter("exam_time_limit"));
        String examdesc=request.getParameter("exam_desc");

        System.out.println(examname+"开始时间"+examstartdate+"结束时间"+examenddate+"分数"+examscore+"考试时间"+examtimelimit+"考试描述"+examdesc);

        int num=dao.addKao(examname,examstartdate,examenddate,examscore,examtimelimit,examdesc);
        if(num>0){

            response.sendRedirect("/tkxt.jsp");
        }else{
            response.sendRedirect("/sjbx.jsp");
        }

    }
}
